#pragma once

#include <QVector>
#include "../data/atom.h"
#include "../data/reg3dvolumedata.h"
#include "../data/geometrydata.h"
#include "../math/Vector3.h"

namespace PBVP {
	/// Construct volume data from a set of atoms
	class BlurMap {
	public:
		/// 
		BlurMap();
		/// 
		~BlurMap() {}

		/// 
		double blobby() const {
			return m_Blobby;
		}
		/// 
		void setBlobby(double blob) {
			m_Blobby = blob;
		}
		/// 
		void getDimension(unsigned int dim[3]) const {
			dim[0] = m_Dim[0];
			dim[1] = m_Dim[1];
			dim[2] = m_Dim[2];
		}
		/// 
		void setDimension(unsigned int dim[3]) {
			m_Dim[0] = dim[0];
			m_Dim[1] = dim[1];
			m_Dim[2] = dim[2];
		}
		/// 
		void getMinMaxExt(double minExt[3], double maxExt[3]) const {
			for (int i = 0; i < 3; i++)
			{
				minExt[i] = m_MinExt[i];
				maxExt[i] = m_MaxExt[i];
			}
		}
		/// 
		void setMinMaxExt(double minExt[3], double maxExt[3]) {
			for (int i = 0; i < 3; i++)
			{
				m_MinExt[i] = minExt[i];
				m_MaxExt[i] = maxExt[i];
			}
		}
		/// 
		void setMinMaxExt(const Vector3& minVec, const Vector3& maxVec) {
			for (int i = 0; i < 3; i++)
			{
				m_MinExt[i] = minVec[i];
				m_MaxExt[i] = maxVec[i];
			}
		}

		///
		Reg3DVolumeData* constructVolume(const QVector<Atom>& atoms);

		///
		GeometryData* constructSurface(const QVector<Atom>& atoms);

	private:
		double m_Blobby;
		float m_IsoDensity;
		unsigned int m_Dim[3];
		double m_MinExt[3], m_MaxExt[3];

		float evalDensity(const Atom& atom, const Vector3& pos);

		void computeMinMaxExt(const QVector<Atom>& atoms);
	};
}